package com.example.smart.ui.activity.home

import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.example.lib.extend.setOnDoubleClickListener
import com.example.lib.utils.glide.GlideCFitXyTransform
import com.example.lib.utils.statusbar.StatusBarUtils
import com.example.smart.R
import com.example.smart.base.ui.activity.BaseTitleBarActivity
import com.example.smart.databinding.ActivityEverydayTestBinding
import com.example.smart.utils.DisplayUtils
import com.youth.banner.adapter.BannerImageAdapter
import com.youth.banner.holder.BannerImageHolder
import com.youth.banner.indicator.CircleIndicator
import com.youth.banner.listener.OnPageChangeListener
import com.youth.banner.transformer.ZoomOutPageTransformer


class EverydayTestActivity : BaseTitleBarActivity<ActivityEverydayTestBinding>() {

    override fun layoutID() = R.layout.activity_everyday_test

    override fun initView() {
        StatusBarUtils.setStateAndNavigationBar(this@EverydayTestActivity,
            statusBarColor = com.example.lib.R.color.black_ececf8)
        setTitle("难度选择")
        setAppBarColor(getColor(com.example.lib.R.color.black_ececf8))
        binding.Banner.setAdapter(object : BannerImageAdapter<Int>(mutableListOf(R.mipmap.icon_back101,
            R.mipmap.icon_back100,
            R.mipmap.icon_back102)) {
            override fun onBindView(holder: BannerImageHolder, data: Int, position: Int, size: Int) {
                Glide.with(holder.itemView).load(data).apply(RequestOptions().transform(GlideCFitXyTransform()))
                    .into(holder.imageView)
            }
        }).addBannerLifecycleObserver(this) //添加生命周期观察者
            .setIndicator(CircleIndicator(this)).isAutoLoop(false).setPageTransformer(ZoomOutPageTransformer())
            .setBannerGalleryEffect(30, 20).setIndicator(CircleIndicator(this@EverydayTestActivity), false)

    }

    override fun initListener() {
        binding.Go.setOnDoubleClickListener {
            DisplayUtils.toQuestion(this@EverydayTestActivity)
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        //销毁
        binding.Banner.destroy()
    }

}